﻿using SqlSugar;

namespace EasyTemplate.Tool.Entity;

/// <summary>
/// 属性
/// </summary>
[SugarTable(null, "属性")]
[SugarIndex("ParentId", nameof(ParentId), OrderByType.Desc)]
public partial class TProductProperty : EntityBaseId, IDeletedFilter
{
    /// <summary>
    /// 属性名称
    /// </summary>
    [SugarColumn(ColumnDescription = "属性名称", IsNullable = true)]
    public string Name { get; set; }
    /// <summary>
    /// 父级id
    /// </summary>
    [SugarColumn(ColumnDescription = "父级id", IsNullable = true)]
    public long ParentId { get; set; }
    /// <summary>
    /// 软删除,1:删除，0:不删除
    /// </summary>
    [SugarColumn(ColumnDescription = "软删除", DefaultValue = "0")]
    public virtual bool IsDelete { get; set; } = false;

    /// <summary>
    /// 子集
    /// </summary>
    [SqlSugar.SugarColumn(IsIgnore = true)]
    public List<TProductProperty> Children { get; set; }
}

public class TProductPropertySeedData : ISeedData<TProductProperty>
{
    public IEnumerable<TProductProperty> Generate()
        =>
        [
            new TProductProperty() { Id = 1, Name="默认", ParentId = 0 },
            new TProductProperty() { Id = 2, Name="默认", ParentId = 1 },
            new TProductProperty() { Id = 3, Name="颜色", ParentId = 0 },
            new TProductProperty() { Id = 4, Name="红色", ParentId = 3 },
            new TProductProperty() { Id = 5, Name="绿色", ParentId = 3 },
            new TProductProperty() { Id = 6, Name="黄色", ParentId = 3 },
            new TProductProperty() { Id = 7, Name="口味", ParentId = 0 },
            new TProductProperty() { Id = 8, Name="水果", ParentId = 7 },
            new TProductProperty() { Id = 9, Name="可乐", ParentId = 7 },
        ];
}
